<template>
	<view class="content">
		<view class="list-group" v-if="list.length !=0">
			<view v-for="(item,index) in list" :key="item.id" class="list-item" @click="handleClick(item)">
				<view style="display: flex;justify-content: space-between;font-size: 28rpx;margin-bottom: 20rpx;">
					<view style="display: flex;align-items: center;">
						<view style="margin-right: 20rpx;color: #2979ff;" class="list-item-index">{{index+1}}</view>
						<view>{{item.name}}</view>
					</view>
					<view style="color: #999;font-size: 24rpx;">{{item.reportingMonth}}</view>
				</view>
				<u-line></u-line>
				<view style="font-size: 28rpx;">
					<u-row justify="space-between" customStyle="margin-top: 10px">
						<u-col span="6">
							<view style="display: flex;align-items: center;">
								<view style="color: #999999;">姓名：</view>
								<view>{{item.empname}}</view>
							</view>
						</u-col>
						<u-col span="6">
							<view style="display: flex;align-items: center;">
								<view style="color: #999999;">部门：</view>
								<view>{{item.orgName}}</view>
							</view>
						</u-col>
					</u-row>
					<u-row justify="space-between" customStyle="margin-top: 10px">
						<u-col span="6">
							<view style="display: flex;align-items: center;">
								<view style="color: #999999;">当前评分：</view>
								<view>{{item.finalScore}}</view>
							</view>
						</u-col>
						<u-col span="6">
							<view style="display: flex;align-items: center;">
								<view style="color: #999999;">考核等级：</view>
								<view>{{item.assessmentGrade}}</view>
							</view>
						</u-col>
					</u-row>
					<u-row justify="space-between" customStyle="margin-top: 10px">
						<u-col span="6">
							<view style="display: flex;align-items: center;">
								<view style="color: #999999;">流程状态：</view>
								<view v-if="item.status== -1" class="status" style="color: #8B0000;">停用</view>
								<view v-if="item.status== -2 || item.status== -3" class="status"
									style="color: #DC143C;">退回</view>
								<view v-if="item.status== 1" class="status" style="color: #008000;">待提交</view>
								<view v-if="item.status== 2" class="status" style="color: #0000CD;">部门领导审核</view>
								<view v-if="item.status== 3" class="status" style="color: #0000CD;">分管领导考核</view>
								<view v-if="item.status== 100" class="status" style="color: #000000;">处理完毕</view>
							</view>
						</u-col>
						<u-col span="6">
							<view style="display: flex;justify-content: flex-end;">
								<span class="actions">审核</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
		</view>
		<u-empty mode="data" icon="../../../static/images/not-data.png" text="暂无数据" v-else>
		</u-empty>
	</view>
</template>

<script>
	import dayjs from 'dayjs'
	import {
		GetReviewAssessment
	} from '@/api/main.js'
	export default {
		data() {
			return {
				list: [],
				pagination: {
					pageNum: 1,
					pageSize: 10,
					totalPageNum: 0,
				}
			}
		},
		onShow() {
			const launchOptions = uni.getLaunchOptionsSync();
			console.log('--------')
			console.log(launchOptions.promise)
			console.log('--------')
			if (launchOptions.promise) {
				launchOptions.promise.then(() => {
					// 在这里执行内页操作，此时App.vue中的异步操作已经完成
					console.log('App.vue中的操作已完成，开始执行内页操作');

				});
			}
			// console.log(dayjs().format('YYYY-MM-DD HH:mm:ss'))
			this.list = []
			this.pagination.pageNum = 1
			this.getData()
		},
		methods: {
			getData() {
				let formData = new FormData();
				formData.append('empId', uni.getStorageSync('empid'));
				formData.append('pageNum', this.pagination.pageNum);
				formData.append('pageSize', this.pagination.pageSize);
				formData.append('taskStatus', "wait");
				GetReviewAssessment(formData).then(response => {
					if (response.data != null) {
						this.list = this.list.concat(response.data)
						this.pagination.totalPageNum = Math.ceil(response.total * this.pagination.pageNum)
						uni.stopPullDownRefresh();
					}

				})
			},
			handleClick(item) {
				uni.navigateTo({
					url: `/pages/todo-list/index/agency-details?id=${item.id}&source=0`
				})
			}
		},
		// 下拉刷新时触发的函数
		onPullDownRefresh() {
			console.log("下拉刷新时触发的函数")
			this.list = []
			this.pagination.pageNum = 1
			this.getData()

		},
		// 上拉触底时触发的函数
		onReachBottom() {
			console.log("上拉触底时触发的函数")
			if (this.pagination.pageNum <= this.pagination.totalPageNum) {
				this.pagination.pageNum += 1
				this.getData()
			}

		},
	}
</script>

<style scoped lang="scss">
	.list-group {
		padding: 20rpx;

		.list-item {
			padding: 30rpx;
			background: #ecf5ff;
			margin-bottom: 30rpx;
			border-radius: 10rpx;

			.list-item-index {
				display: flex;
				border: 1px solid #5F9EA0;
				width: 40rpx;
				height: 40rpx;
				align-items: center;
				justify-content: center;
				border-radius: 44rpx;
				font-size: 24rpx;

			}

			.status {
				color: #008B8B;
				font-weight: 400;
			}

			.actions {
				background: #2db7f5;
				color: #ffffff;
				padding: 4rpx 18rpx;
				border-radius: 5rpx;
				font-size: 26rpx;
			}
		}
	}
</style>